package cn.heygod.sample.config;

import cn.heygod.airsql.executor.SqlExecutor;
import cn.heygod.airsql.executor.SqlExecutorManager;
import cn.heygod.airsql.executor.jdbc.JDBCTemplateExecutor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.core.JdbcTemplate;

/**
 * @className: OkSqlConfiguration
 * @author: Simon
 * @description: TODO
 * @date: 2024/1/28 19:16
 * @version: 1.0
 */
@Configuration
public class OkSqlConfiguration {

    @Autowired
    private JdbcTemplate jdbcTemplate;

    @Bean
    public SqlExecutor createSqlExecutor(){
        JDBCTemplateExecutor executor = new JDBCTemplateExecutor();
        executor.setJdbcTemplate(jdbcTemplate);
        SqlExecutorManager.setSqlExecutor(executor);
        return executor;
    }
}
